/*******************************************************************************
 * Copyright (c) 2008 Smart Mai(smardio@gmail.com).
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Public License v2.0
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 * 
 * Contributors:
 *     Smart Mai(smardio@gmail.com) - initial API and implementation
 ******************************************************************************/
package com.smartdio.company.views;

import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.layout.GridData;

/**
 * @author smart
 *
 */
public class CompanyEditPanel extends Composite {

	private Label labelName = null;
	private Text txtName = null;
	private Label labelDescrip = null;
	private Text txtDescription = null;

	/**
	 * @param parent
	 * @param style
	 */
	public CompanyEditPanel(Composite parent, int style) {
		super(parent, style);
		initialize();
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		/* Before this is run, be sure to set up the launch configuration (Arguments->VM Arguments)
		 * for the correct SWT library path in order to run with the SWT dlls. 
		 * The dlls are located in the SWT plugin jar.  
		 * For example, on Windows the Eclipse SWT 3.1 plugin jar is:
		 *       installation_directory\plugins\org.eclipse.swt.win32_3.1.0.jar
		 */
		Display display = Display.getDefault();
		Shell shell = new Shell(display);
		shell.setLayout(new FillLayout());
		shell.setSize(new Point(300, 200));
		new CompanyEditPanel(shell, SWT.NONE);
		shell.open();

		while (!shell.isDisposed()) {
			if (!display.readAndDispatch())
				display.sleep();
		}
		display.dispose();
	}

	private void initialize() {
		GridData gridData2 = new GridData();
		gridData2.verticalAlignment = org.eclipse.swt.layout.GridData.BEGINNING;
		GridData gridData1 = new GridData();
		gridData1.grabExcessHorizontalSpace = true;
		gridData1.horizontalAlignment = org.eclipse.swt.layout.GridData.FILL;
		gridData1.verticalAlignment = org.eclipse.swt.layout.GridData.FILL;
		gridData1.heightHint = -1;
		gridData1.grabExcessVerticalSpace = true;
		GridData gridData = new GridData();
		gridData.grabExcessHorizontalSpace = true;
		gridData.horizontalAlignment = org.eclipse.swt.layout.GridData.FILL;
		GridLayout gridLayout = new GridLayout();
		gridLayout.numColumns = 2;
		labelName = new Label(this, SWT.NONE);
		labelName.setText("名称:");
		txtName = new Text(this, SWT.BORDER);
		txtName.setLayoutData(gridData);
		labelDescrip = new Label(this, SWT.NONE);
		labelDescrip.setText("备注:");
		labelDescrip.setLayoutData(gridData2);
		txtDescription = new Text(this, SWT.MULTI | SWT.WRAP | SWT.V_SCROLL | SWT.BORDER);
		txtDescription.setLayoutData(gridData1);
		this.setLayout(gridLayout);
		setSize(new Point(325, 118));
	}
	
	/**
	 * 取得企业的名称
	 * @return
	 */
	public String getName(){
		return txtName.getText();
	}
	
	/**
	 * 取得企业的说明
	 * @return
	 */
	public String getDescription(){
		return txtDescription.getText();
	}

}  //  @jve:decl-index=0:visual-constraint="10,10"
